﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RastinArgham.Website.Controllers
{
    public class CampaignController : Controller
    {
        public ActionResult Index(String campaignCode, String link, String linkAction)
        {
            if (!String.IsNullOrEmpty(campaignCode))
            {
                HttpCookie cookie = new HttpCookie("Campaign", campaignCode);
                cookie.Expires = DateTime.Now.AddMonths(12);
                Response.Cookies.Add(cookie);

                if (!String.IsNullOrEmpty(link))
                {
                    if (!String.IsNullOrEmpty(linkAction))
                        return RedirectToAction(linkAction, link);
                    else
                        return RedirectToAction("Index", link);
                }
            }

            return RedirectToRoute("Services");
        }
    }
}
